package algorithm.doublePointer;

// https://leetcode.cn/problems/he-wei-sde-liang-ge-shu-zi-lcof/description/
public class LCR179 {
    public int[] twoSum(int[] price, int target) {
        int l = 0, r = price.length - 1;

        while (l < r) {
            if (price[l] + price[r] > target) {
                r--;
            } else if (price[l] + price[r] < target) {
                l++;
            } else {
                break;
            }
        }

        return new int[]{price[l], price[r]};
    }
}
